using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ChipSharp
{

    /* <Summary>
     * Tile-based chipsharp entity
     * </Summary>
     */
    class Charp
    {
        /* layer */
        public int Priority { set; get; }

        /* Position */
        public int X { get; set; }
        public int Y { get; set; }

        public Charp Upper = null;

        public Charp(int x, int y)
        {
            X = x;
            Y = y;
        }

        public virtual void Draw(Graphics graph, Rectangle rect)
        {
            if (Upper != null)
            {
                Upper.Draw(graph, rect);
            }
        }

        public virtual bool Remove(Charp charp)
        {
            if (Upper == charp)
            {
                Upper = charp.Upper;
                return true;
            }
            else
            {
                return Upper.Remove(charp);
            }
        }

        public virtual void AddToTop(Charp charp)
        {
            if (Upper == null)
            {
                Upper = charp;
            }
            else
            {
                Upper.AddToTop(charp);
            }
        }

        public virtual void Step(World world)
        {
        }

        public virtual void SortPile(World world)
        {
        }

        public virtual bool Block(bool inside, World.Direction direction)
        {
            return false;
        }
    }
}
